﻿using SHKF.B2C.Model;
using SHKF.B2C.Model.Dto;
using SHKF.B2C.Model.Entity.Center;
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using WQDSkin.Forms.Component; 

namespace SHKF.B2C.Mannage.AdminUI.View.CenterInfo.User
{
    /// <summary>
    /// frmUserEdit.xaml 的交互逻辑
    /// </summary>
    public partial class frmUserEdit : BasePage
    {
        public frmUserEdit()
        {
            InitializeComponent();
        }

        protected override void OnInitialized(EventArgs e)
        {
            base.OnInitialized(e);

            List<KeyValueIntModel> sexList = new List<KeyValueIntModel>();
            sexList.Add(new KeyValueIntModel() { Name = "男", Value = 1 });
            sexList.Add(new KeyValueIntModel() { Name = "女", Value = 0 });
            this.cbxSex.ItemsSource = sexList;
        }

        private async void btnSave_Click(object sender, RoutedEventArgs e)
        {
            if (base.Verifiy())
            {
                UserEntity user = (UserEntity)this.DataContext;
                DataDto<UserEntity> dto = await GL.HttpClientManage.SaveUser(user);
                if (dto.error == null)
                {
                    this.DataContext = dto.data;
                }
                else
                {
                    MessageBox.Show(dto.error.msg);
                }
            }
        }

        private void btnGoBack_Click(object sender, RoutedEventArgs e)
        {
            base.GoBack(null);
        }

        private void BasePage_Loaded(object sender, RoutedEventArgs e)
        {
            


        }
    }
}
